package com.qining618.common.exception;

import com.qining618.common.result.ErrorCode;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * @author flt
 * @date 2019-08-16
 */
@EqualsAndHashCode(callSuper = true)
@Data
public class BusinessException extends RuntimeException {

    private static final long serialVersionUID = 4967201849236459196L;

    private ErrorCode errorCode;
    private Object data;

    public BusinessException(ErrorCode errorCode) {
        super(errorCode.getMessage());
        this.errorCode = errorCode;
    }

    public BusinessException(ErrorCode errorCode, String message) {
        super(message);
        this.errorCode = errorCode;
    }

    public BusinessException(ErrorCode errorCode, String message, Object data) {
        super(message);
        this.errorCode = errorCode;
        this.data = data;
    }

    public BusinessException(String message) {
        super(message);
        this.errorCode = ErrorCode.FAILED;
    }

    public BusinessException(Throwable cause) {
        super(cause);
    }

    public BusinessException(String message, Throwable cause) {
        super(message, cause);
    }

}
